<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("comctrls.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Queue_View extends Page
{
       public $edRtype = null;
       public $edReason = null;
       public $edProdType = null;
       public $edVolume = null;
       public $edCustname = null;
       public $dpReturnPlantTime = null;
       public $dpDepartClientTime = null;
       public $dpActualUnloadTime = null;
       public $dpArrivalClientTime = null;
       public $dpEstReturnTime = null;
       public $dpDepPlantTime = null;
       public $dpLoadConfirmedTime = null;
       public $dpArrivalPlantTime = null;
       public $dpIsuueLoadTime = null;
       public $dpReturnPlant = null;
       public $dpDepartClient = null;
       public $dpActualUnload = null;
       public $dpArrivalClient = null;
       public $dpEstReturn = null;
       public $dpDepPlant = null;
       public $dpLoadConfirmed = null;
       public $dpIsuueLoad = null;
       public $dpArrivalPlant = null;
       public $edPlate = null;
       public $edDrcode = null;
       public $edHcode = null;
       public $edHname = null;
       public $Label33 = null;
       public $memoRemarks = null;
       public $Label32 = null;
       public $Label31 = null;
       public $Label29 = null;
       public $Label30 = null;
       public $edHitMiss = null;
       public $Label22 = null;
       public $Label15 = null;
       public $Label28 = null;
       public $edLSite = null;
       public $Label27 = null;
       public $edFname = null;
       public $Label26 = null;
       public $edLname = null;
       public $Label25 = null;
       public $edHtype = null;
       public $Label23 = null;
       public $listBoxHelpers = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $Image3 = null;
       public $Label21 = null;
       public $Label20 = null;
       public $Label19 = null;
       public $Label18 = null;
       public $Label17 = null;
       public $Label16 = null;
       public $Label14 = null;
       public $Label13 = null;
       public $edCustno = null;
       public $Label12 = null;
       public $edCustLoc = null;
       public $Label11 = null;
       public $Label10 = null;
       public $Image1 = null;
       public $edTruckType = null;
       public $Label9 = null;
       public $Label8 = null;
       public $Label7 = null;
       public $Label6 = null;
       public $Label5 = null;
       public $edTrip = null;
       public $Label4 = null;
       public $edSO = null;
       public $Label3 = null;
       public $edQueue = null;
       public $Label2 = null;
       public $edSequence = null;
       public $Label1 = null;
       public $Image2 = null;
       public $edDR = null;
       public $lblengine = null;
       public $hfAutoid = null;
       public $JTJavaScript1 = null;
       public $hfHelper = null;
       public $hfInitHelpers = null;
       public $JTSiteTheme1 = null;
       function Queue_ViewCreate($sender, $params)
       {
       $autoid = $_GET['autoid'];
       if($autoid!='')
       $this->hfAutoid->setValue(base64_decode($autoid));

       $query_sel = "SELECT * FROM queue_tbl WHERE autoid='".$this->hfAutoid->getValue()."'";
       $result_sel = mysql_query($query_sel) or die("SELECT QUEUE ".mysql_error());
       $row_sel = mysql_fetch_array($result_sel);

       $dr_id = $row_sel['driver_id'];
       $query_emp = "SELECT * FROM employee_tbl WHERE autoid='".$dr_id."'";
       $result_emp = mysql_query($query_emp) or die("SELECT EMP ".mysql_error());
       $row_emp = mysql_fetch_array($result_emp);

       $helpers_id = explode(',',$row_sel['helpers_id']);
       $this->listBoxHelpers->Clear();
       foreach($helpers_id as $hid)
       {
        $query_helper = "SELECT lname, fname FROM employee_tbl WHERE autoid='".$hid."'";
        $result_helper = mysql_query($query_helper) or die("SELECT HELPER ".mysql_error());
        $row_helper = mysql_fetch_array($result_helper);
        $this->listBoxHelpers->AddItem($row_helper['lname'].", ".$row_helper['fname'],'',$row_helper['lname'].", ".$row_helper['fname']);
       }

       $this->edTrip->Text = $row_sel['trip_no'];
       $this->edDR->Text = $row_sel['dr_no'];
       $this->edPlate->Text = $row_sel['plate_no'];

       $this->edDrcode->Text = $row_sel['driver_code'];
       $this->edLname->Text = $row_emp['lname'];
       $this->edFname->Text = $row_emp['fname'];

       $this->edHcode->Text = $row_sel['hauler_code'];
       $this->edHname->Text = $row_sel['hauler_name'];

       $this->edTruckType->Text = $row_sel['truck_type'];
       $this->edLSite->Text = $row_sel['loading_site'];

       $this->edCustname->Text = $row_sel['cust_name'];
       $this->edCustno->Text = $row_sel['cust_no'];
       $this->edCustLoc->Text = $row_sel['cust_loc'];
       $this->edVolume->Text = $row_sel['cust_vol'];
       $this->edCustLoc->Text = $row_sel['cust_loc'];
       $this->edProdType->Text = $row_sel['cust_prod'];

       $this->dpArrivalPlant->Text = $row_sel['arrival_at_plant'];
       $this->dpIsuueLoad->Text = $row_sel['issue_loading_note'];
       $this->dpLoadConfirmed->Text = $row_sel['load_confirmed'];
       $this->dpDepPlant->Text = $row_sel['dept_on_plant'];
       $this->dpEstReturn->Text = $row_sel['est_return'];

       $this->dpArrivalPlantTime->Text = $row_sel['arrival_at_plant_time'];
       $this->dpIsuueLoadTime->Text = $row_sel['issue_loading_note_time'];
       $this->dpLoadConfirmedTime->Text = $row_sel['load_confirmed_time'];
       $this->dpDepPlantTime->Text = $row_sel['dept_on_plant_time'];
       $this->dpEstReturnTime->Text = $row_sel['est_return_time'];

       $this->dpArrivalClient->Text = $row_sel['arrival_at_client'];
       $this->dpActualUnload->Text = $row_sel['actual_unloading'];
       $this->dpDepartClient->Text = $row_sel['departure_at_client'];
       $this->dpReturnPlant->Text = $row_sel['return_to_plant'];

       $this->dpArrivalClientTime->Text = $row_sel['arrival_at_client_time'];
       $this->dpActualUnloadTime->Text = $row_sel['actual_unloading_time'];
       $this->dpDepartClientTime->Text = $row_sel['departure_at_client_time'];
       $this->dpReturnPlantTime->Text = $row_sel['return_to_plant_time'];

       $this->memoRemarks->Text = $row_sel['remarks'];
       $this->edHitMiss->Text = $row_sel['hit_miss'];
       $this->edReason->Text = $row_sel['reason'];
       $this->edRtype->Text = $row_sel['reason_type'];

       //hidden
       //$this->edSequence->Text = $row_sel['sequence_no'];
       //$this->edQueue->Text = $row_sel['queue_no'];
       //$this->edSO->Text = $row_sel['so_no'];
       //$this->edHtype->Text = $row_sel['hauler_type'];
       }


}

global $application;

global $Queue_View;

//Creates the form
$Queue_View=new Queue_View($application);

//Read from resource file
$Queue_View->loadResource(__FILE__);

//Shows the form
$Queue_View->show();

?>